/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	SContractQueryParamConverter.java
 * Created：		2016年9月5日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.contract.converter;

import java.util.ArrayList;

import org.springframework.core.convert.converter.Converter;

import com.thor.palmmall.rest.contract.AQueryContractParam;
import com.thor.palmmall.spi.contract.SQueryContractParam;

/**
 * @author wolv
 *
 */
public class SQueryContractParamConverter
    implements Converter<AQueryContractParam, SQueryContractParam> {

  public static SQueryContractParamConverter getInstance() {
    if (instance == null)
      instance = new SQueryContractParamConverter();
    return instance;
  }

  private static SQueryContractParamConverter instance;

  private SQueryContractParamConverter() {
  }

  @Override
  public SQueryContractParam convert(AQueryContractParam source) {
    if (source == null)
      return null;

    SQueryContractParam target = new SQueryContractParam();
    target.setPage(source.getPage());
    target.setPageSize(source.getPageSize());
    target.setStores(new ArrayList<String>());
    if (source.getStores() != null)
      target.getStores().addAll(source.getStores());
    target.setKeyword(source.getKeyword());
    target.setOrder(source.getOrder());
//    if (source.getBizState() != null) {
//      target.setBizState(source.getBizState());
//    }
    return target;
  }

}
